#ifdef __GNUC__

#define max(x, y) (((x) > (y)) ? (x) : (y))
#define min(x, y) (((x) < (y)) ? (x) : (y))

// abs is now predefined
// template<typename T> T abs (T a)			{ return (a<T(0)) ? -a : a; }

inline int lsr(int x, int n)
{
    return int(((unsigned int)x) >> n);
}

/******************************************************************************
*******************************************************************************

                                                               VECTOR INTRINSICS

*******************************************************************************
*******************************************************************************/

// inline void *aligned_calloc(size_t nmemb, size_t size) { return
// (void*)((unsigned)(calloc((nmemb*size)+15,sizeof(char)))+15 & 0xfffffff0); }
inline void* aligned_calloc(size_t nmemb, size_t size)
{
    return (void*)((size_t)(calloc((nmemb * size) + 15, sizeof(char))) + 15 & ~15);
}

// clang-format off
<<includeIntrinsic>>
    // clang-format on

    /******************************************************************************
*******************************************************************************

                        ABSTRACT USER INTERFACE

*******************************************************************************
*******************************************************************************/

    class UI
{
    bool fStopped;

   public:
    UI() : fStopped(false) {}
    virtual ~UI() {}

    virtual void addButton(char* label, float* zone)        = 0;
    virtual void addToggleButton(char* label, float* zone)  = 0;
    virtual void addCheckButton(char* label, float* zone)   = 0;
    virtual void addVerticalSlider(char* label, float* zone, float init, float min,
                                   float max, float step)   = 0;
    virtual void addHorizontalSlider(char* label, float* zone, float init, float min,
                                     float max, float step) = 0;
    virtual void addNumEntry(char* label, float* zone, float init, float min, float max,
                             float step)                    = 0;

    virtual void openFrameBox(char* label)      = 0;
    virtual void openTabBox(char* label)        = 0;
    virtual void openHorizontalBox(char* label) = 0;
    virtual void openVerticalBox(char* label)   = 0;
    virtual void closeBox()                     = 0;

    virtual void run() = 0;

    void stop() { fStopped = true; }
    bool stopped() { return fStopped; }
};

/******************************************************************************
*******************************************************************************

                            FAUST DSP

*******************************************************************************
*******************************************************************************/

//----------------------------------------------------------------
//  abstract definition of a signal processor
//----------------------------------------------------------------

class dsp
{
   protected:
    int fSamplingFreq;

   public:
    dsp() {}
    virtual ~dsp() {}

    virtual int getNumInputs()                                     = 0;
    virtual int getNumOutputs()                                    = 0;
    virtual void buildUserInterface(UI* interface)                 = 0;
    virtual void init(int samplingRate)                            = 0;
    virtual void compute(int len, float** inputs, float** outputs) = 0;
};

//----------------------------------------------------------------------------
//  FAUST generated signal processor
//----------------------------------------------------------------------------
// clang-format off
<<includeclass>>
    // clang-format on
